interface JsonData {
	[key: string]: FormDataEntryValue | FormDataEntryValue[] | null;
}
type getFormData = (form: HTMLFormElement | null) => JsonData | undefined;
const getFormData: getFormData = (form) => {
	const jsondata: JsonData = {};
	if (!form) return;
	const formdata = new FormData(form);
	formdata.forEach((value, key) => {
		if (!jsondata[key]) {
			jsondata[key] = formdata.getAll(key).length > 1 ? formdata.getAll(key) : formdata.get(key);
		}
	});
	return jsondata;
};
export { getFormData };
